import java.util.ArrayList;

import org.w3c.dom.Attr;

public class LoadedAttributes extends LoadedSettings
{
	ArrayList<Attribute> attributes;
	static LoadedAttributes rInstance;
	
	public ArrayList<Attribute> getAttributes()
	{
		return attributes;
	}

	static public LoadedAttributes getInstance(String file)
	{
		if(rInstance == null)
		{
			rInstance = new LoadedAttributes(file);
		}
		return rInstance;
	}
	
	static public LoadedAttributes getInstance()
	{
		if(rInstance == null)
		{
			rInstance = new LoadedAttributes(defaultAttributesFilename);
		}
		return rInstance;
	}
	
	LoadedAttributes(String file)
	{
		super(file);
		attributes = new ArrayList<Attribute>();
		loadAttributes();
	}
	
	void loadAttributes()
	{
		ArrayList<String> lines = load();
		for (String line : lines) 
		{
			String[] description = line.split(SPLITTER);
			/*
			 * descpription[0] == Attribute.name 	(String)
			 * descpription[1] == Attribute.value 	(Integer)
			 * descpription[2] == Attribute.name	(boolean)
			 * 
			 * */
			attributes.add(new Attribute(
					description[0],
					Integer.parseInt(description[1]),
					Boolean.parseBoolean(description[2])));
		}
		System.err.println("LOADED ATTRIBUTES\n========================================");
		for (Attribute atrib : attributes) 
		{
			System.err.println(atrib.toString());
		}
	}
}